/**
 * 
 */
package edu.rit.cs.web.pages;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.spring.injection.annot.SpringBean;

import edu.rit.cs.core.pojos.AUser;
import edu.rit.cs.core.services.daos.AdministratorDAO;
import edu.rit.cs.web.panels.LoginPanel;
import edu.rit.cs.web.panels.StockMarketPanel;

/**
 * This page allows the administrator to add or delete business entities and
 * services. The administrator must login before accessing those options.
 * 
 * @see StockMarketPanel
 * @see LoginPanel
 * 
 * @author Abhishek Shrestha (axs1430)
 * @author Juan Saldana (jjs6109)
 * @author Victor Alvarez (vxa1557)
 */
public class AdminPage extends WebPage {

  @SpringBean
  private AdministratorDAO ad;

  public AdminPage() {
    final StockMarketPanel stockMarketPanel =
      new StockMarketPanel("stockMarketPanel");
    stockMarketPanel.setVisible(false);

    add(new LoginPanel("loginPanel"){
      private static final long serialVersionUID = 1L;

      @Override
      protected AUser getUserByName(String username) {
        return ad.findByUsername(username);
      }
      
      @Override
      protected void hide() {
        setVisible(false);
        stockMarketPanel.setVisible(true);
      }      
    });

    add(stockMarketPanel);
  }

}
